-- this small addon simply loads some more custom events into SCT
-- without touching the files. This is necessary for autoupdater
-- users.

local sct_rhidon_customs = {
	[1] = {name="Cheap Heal!", type="buffself", search="Healing Trance", r=0/256, g=255/256, b=128/256, iscrit=1, class={"Paladin","Shaman","Druid","Priest"}},
	[2] = {name="Revitalize!", search="Revitalize", r=0/256, g=255/256, b=128/256, class={"Shaman"}},
	[3] = {name="Fast HW charged!", type="buffself", search="Wave Trance", r=0/256, g=255/256, b=128/256, iscrit=1, class={"Shaman"}},
}

function sct_rhidon_nextfreeidx(evtlist, startat)
	if not evtlist then
		return -1
	end
	if not startat then
		startat = 1
	end
	for i = startat, 100, 1 do
		if not evtlist[i] then
			return i
		end
	end
	return -1
end

if SCT.EventConfig then
	local curpos = 1
	local nextfree = 0
	for key, value in ipairs(sct_rhidon_customs) do
		nextfree = sct_rhidon_nextfreeidx(SCT.EventConfig, curpos)
		if nextfree == -1 then
			-- error
			DEFAULT_CHAT_FRAME:AddMessage("sct_rhidon: SCT EventConfig not readable, this shouldn't ever happen.")
			break
		end
		DEFAULT_CHAT_FRAME:AddMessage(string.format("sct_rhidon: Injecting %s at position %i", value["name"], nextfree))
		SCT.EventConfig[nextfree] = value
		SCT:CacheCustomEvents()
		curpos = nextfree + 1
	end
end